<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template name="get_month_name">
		<xsl:param name="month_number"/>
		<xsl:param name="type" select="'month_capital'"/>
		<xsl:choose>
			<xsl:when test="$type = 'with_day'">
				<xsl:choose>
					<xsl:when test="$month_number = 1">января</xsl:when>
					<xsl:when test="$month_number = 2">февраля</xsl:when>
					<xsl:when test="$month_number = 3">марта</xsl:when>
					<xsl:when test="$month_number = 4">апреля</xsl:when>
					<xsl:when test="$month_number = 5">мая</xsl:when>
					<xsl:when test="$month_number = 6">июня</xsl:when>
					<xsl:when test="$month_number = 7">июля</xsl:when>
					<xsl:when test="$month_number = 8">августа</xsl:when>
					<xsl:when test="$month_number = 9">сентября</xsl:when>
					<xsl:when test="$month_number = 10">октября</xsl:when>
					<xsl:when test="$month_number = 11">ноября</xsl:when>
					<xsl:when test="$month_number = 12">декабря</xsl:when>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="$type = 'month_capital'">
				<xsl:choose>
					<xsl:when test="$month_number = 1">Январь</xsl:when>
					<xsl:when test="$month_number = 2">Февраль</xsl:when>
					<xsl:when test="$month_number = 3">Март</xsl:when>
					<xsl:when test="$month_number = 4">Апрель</xsl:when>
					<xsl:when test="$month_number = 5">Май</xsl:when>
					<xsl:when test="$month_number = 6">Июнь</xsl:when>
					<xsl:when test="$month_number = 7">Июль</xsl:when>
					<xsl:when test="$month_number = 8">Август</xsl:when>
					<xsl:when test="$month_number = 9">Сенябрь</xsl:when>
					<xsl:when test="$month_number = 10">Октябрь</xsl:when>
					<xsl:when test="$month_number = 11">Ноябрь</xsl:when>
					<xsl:when test="$month_number = 12">Декабрь</xsl:when>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="$type = 'month_small'">
				<xsl:choose>
					<xsl:when test="$month_number = 1">январь</xsl:when>
					<xsl:when test="$month_number = 2">февраль</xsl:when>
					<xsl:when test="$month_number = 3">март</xsl:when>
					<xsl:when test="$month_number = 4">апрель</xsl:when>
					<xsl:when test="$month_number = 5">май</xsl:when>
					<xsl:when test="$month_number = 6">июнь</xsl:when>
					<xsl:when test="$month_number = 7">июль</xsl:when>
					<xsl:when test="$month_number = 8">август</xsl:when>
					<xsl:when test="$month_number = 9">сентябрь</xsl:when>
					<xsl:when test="$month_number = 10">октябрь</xsl:when>
					<xsl:when test="$month_number = 11">ноябрь</xsl:when>
					<xsl:when test="$month_number = 12">декабрь</xsl:when>
				</xsl:choose>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="count_case">
		<xsl:param name="number"/>
		<!-- nominative case, singular, именительный падеж, ед. число -->
		<xsl:param name="word_ns"/>
		<!-- genitive case, singular, родительный падеж, ед. число -->
		<xsl:param name="word_gs"/>
		<!-- accusative case, plural, винительный падеж, мн. число -->
		<xsl:param name="word_ap"/>
		<xsl:if test="string-length($number) &gt; 0">
			<xsl:variable name="last" select="substring($number, string-length($number), 1)"/>
			<xsl:variable name="last_but_one" select="substring($number, string-length($number)-1, 1)"/>
			<xsl:choose>
				<xsl:when test="$last = '0'">
					<xsl:value-of select="$word_ap"/>
				</xsl:when>
				<xsl:when test="$last_but_one = '1' or $last &gt;= '5' and $last &lt;= '9'">
					<xsl:value-of select="$word_ap"/>
				</xsl:when>
				<xsl:when test="$last &gt;= '2' and $last &lt;= '4'">
					<xsl:value-of select="$word_gs"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$word_ns"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
